#!/bin/bash

PID=`ps x | grep "xbmc\.bin" | awk '{print $1}'`
XPID="/tmp/xbmcpid"

if [ ${PID} ]; then
 echo "XBMC already running as ${PID}"
 exit 1
fi

if [ -e ${XPID} ]; then
 echo "PID File Exists Already Running"
 exit 2
fi

if [ ! -e ${XPID} ]; then
 touch ${XPID}
 /usr/bin/xbmc
fi

rm ${XPID}
exit 0

